package graph.net.commands;

import graph.net.internal.ServiceLocator;

/**
 * @author amahmood
 * Creates command object.
 */
public class CommandFactory
{
    /**
     * @param command
     * @param serviceLocator
     * @return
     */
    public static ICommand createCommand(CommandName command, ServiceLocator serviceLocator)
    {
        ICommand out = null;

        switch (command)
        {
            case add_route:
            case find_all_paths_less_then_distance:
            case find_paths_with_max_stops:
            case find_paths_with_exact_stops:
            case find_shortest_path_length:
            case find_distance:
                out = new GraphCommand(serviceLocator);
                break;
                
            case add_test_data:
                out = new AddTestDataCommand(serviceLocator);
                break;
                
            case run_graph_tests:
                out = new TestAllGraphCommand(serviceLocator);
                break;
                
            case exit:
            case bye:
            case quit:
                out = new ExitCommand();
                break;

            case help:
                out = new HelpCommand();
                break;
            case shutdown:
                out = new ShutdownCommand();
                break;

            default:
                out = new NullCommand(command.label() + " is not implemented yet.");
        }
        return out;
    }
}
